//
// Created by Administrator on 2024/7/9.
//

#ifndef JTT809_BODY_H
#define JTT809_BODY_H
#include "enums/jtt809_linktype.h"
#include "interfaces/base.h"
#include "util/macros.h"

namespace protocol {
    class JTT809Body : public Sizeable, public Serializable, public ToString {
        static inline JTT809Body *instance = nullptr;
        static inline std::once_flag flag;
    protected:
        JTT809LinkType linkType;
        unsigned short msgId;

    public:
        JTT809Body() = default;

        JTT809Body(const JTT809LinkType &link_type, const unsigned short msg_id)
            : linkType(link_type),
              msgId(msg_id) {
        }

        [[nodiscard]] JTT809LinkType link_type() const {
            return linkType;
        }

        [[nodiscard]] unsigned short msg_id() const {
            return msgId;
        }

    protected:
        [[nodiscard]] size_t _size_() const override { return sizeof(*this); }

    public:
        ~JTT809Body() override = default;

        [[nodiscard]] std::string toString() const override {return "";}

        void serialize(MessagePackWriter &writer) override {}

        void deserialize(MessagePackReader &reader) override {}

        static JTT809Body *getInstance() {
            std::call_once(flag, []{
            instance = new JTT809Body();
        });
            return instance;
        }
    };
}

#endif //JTT809_BODY_H
